clear all
clear matrix
pause off
set more off
prog drop _all

* *********************************
* ****** Figures ******************
* *********************************

* Figure 3: Average transaction prices as a function of distance to nuclear plants and waste sites

use "final_transaction.dta", clear
keep if ln_price_m!=. & treatment_nuclear!=. & property_type_f!=. & rank_deprivation_score!=. & ind_mob_2011!=.

generate distance_id=floor(distance_nuclear/2)*2
egen tag_distance_id=tag(distance_id)
egen price_distance=mean(price_m), by(distance_id)
#delimit ;
twoway lpoly price_m distance_nuclear if distance_id<60, color(dknavy) bwidth(2) ||
scatter price_distance distance_id if tag_distance_id & distance_id<60, color(dknavy) msize(small)
xtitle("Distance to NPP (kms)")
ytitle("Average price (pounds)")
ylabel(100000 150000 200000)
yscale(range(100000 240000))
bgcolor("white") graphregion(color(white) margin(l-3 r+1)) 
legend(off) scale(1.3)
;
#delimit cr
graph export "Figure_3a.png", as(png) replace width(1000)
drop distance_id tag_distance_id price_distance

generate distance_id=floor(distance_waste/2)*2
egen tag_distance_id=tag(distance_id)
egen price_distance=mean(price_m), by(distance_id)
#delimit ;
twoway lpoly price_m distance_waste if distance_id<60, color(dkgreen) bwidth(2) ||
scatter price_distance distance_id if tag_distance_id & distance_id<60, color(dkgreen) msize(small)
xtitle("Distance to waste site (kms)")
ytitle("Average price (pounds)")
ylabel(100000 150000 200000)
yscale(range(100000 240000))
bgcolor("white") graphregion(color(white) margin(l-3 r+1)) 
legend(off) scale(1.3)
;
#delimit cr
graph export "Figure_3b.png", as(png) replace width(1000)
drop distance_id tag_distance_id price_distance

* Figure 4: Treatment effects per year (event-study approach)

* Panel a: Deprivation changes between 2004 and 2019

use "final_nationwide.dta", clear
global sample "if lnprice!=. & rank_deprivation_score!=. & year>=2007"
keep ${sample}
global controls "c.bedrooms##i.year c.bathroom##i.year c.floorsz##i.year c.rank_deprivation##i.year"
drop if year*100+month < 200704
replace year = 2007 if inrange(year*100+month, 200704, 200803)
replace year = 2008 if inrange(year*100+month, 200804, 200903)
replace year = 2009 if inrange(year*100+month, 200904, 201003)
replace year = 2010 if inrange(year*100+month, 201004, 201102) 
replace year = 2011 if inrange(year*100+month, 201104, 201203)
replace year = 2012 if inrange(year*100+month, 201204, 201303)
replace year = 2013 if inrange(year*100+month, 201304, 201403)
global vary lnprice
areg ${vary} b2010.year##i.treatment_nuclear i.month##i.year i.group_nuclear##i.year  ${controls} ${sample}, absorb(lsoa_code) robust
generate YEAR=.
generate qestimate=.
generate qvar=.
local i=1
foreach year in 2007 2008 2009 2010 2011 2012 2013 {
replace YEAR=`year' if _n==`i'
replace qestimate=_b[`year'.year#1.treatmen] if _n==`i'
replace qvar=_se[`year'.year#1.treatmen] if _n==`i'
local i=`i'+1
}
generate q5=qestimate-1.96*qvar
generate q95=qestimate+1.96*qvar
#delimit ;
twoway line qestimate YEAR, color(dknavy) ||
scatter qestimate YEAR, color(dknavy) msize(small) || 
line q5 YEAR, color(teal) lwidth(medthin) ||
line q95 YEAR, color(teal) lwidth(medthin)
xtitle("Year")
ytitle("Treatment")
yline(0)
ylabel(-0.10 -0.05 0 0.05)
xlabel(2007 2009 2011 2013)
bgcolor("white") graphregion(color(white) margin(l-3 r+1)) 
legend(off) scale(1.2)
;
#delimit cr
graph export "Figure_4a.png", as(png) replace width(1000)

* Panel b: Deprivation changes between 2004 and 2019

use "final.dta", clear
keep if ln_price!=. & treatment_nuclear!=. & property_type_f!=. & rank_deprivation_score!=. & ind_mob_2011!=.
keep lsoa treatment_nuclear treatment_nuclear_pp treatment_powerplant group_nuclear ind_mob_2011 treatmentw_wk rank_deprivation_score residents_census outmigration_ratio_census inmigration_ratio_census migration_ratio_census nomovers_ratio_census
egen tag=tag(lsoa)
keep if tag==1
merge 1:n lsoa using "deprivation_2004_2019.dta"
keep if _merge==3
drop _merge
generate time_treatment=(year>2011)
global controls ""
global vary panelrank_deprivation_score
areg ${vary} b2010.year##i.treatment_nuclear i.group_nuclear##i.year, absorb(lsoa_code) robust
generate YEAR=.
generate pestimate=.
generate pvar=.
local i=1
foreach year in 2004 2007 2010 2015 2019 {
replace YEAR=`year' if _n==`i'
replace pestimate=_b[`year'.year#1.treatment_nuclear] if _n==`i'
replace pvar=_se[`year'.year#1.treatment_nuclear] if _n==`i'
local i=`i'+1
}
generate p5=pestimate-1.96*pvar
generate p95=pestimate+1.96*pvar
#delimit ;
twoway line pestimate YEAR, color(dknavy) ||
scatter pestimate YEAR, color(dknavy) msize(small) || 
line p5 YEAR, color(teal) lwidth(medthin) ||
line p95 YEAR, color(teal) lwidth(medthin)
xtitle("Year")
ytitle("Treatment")
yline(0)
ylabel(-0.06 -0.04 -0.02 0 0.02)
xlabel(2004 2007 2010 2015 2019)
bgcolor("white") graphregion(color(white) margin(l-3 r+1)) 
legend(off) scale(1.3)
;
#delimit cr
graph export "Figure_4b.png", as(png) replace width(1000)

* Figure 5: Normalized shares of low-skilled workers as a function of distance to nuclear plants in 1971 and 2001--areas with high- and low-mobility industries

use "final_history.dta", clear
generate distance_id=floor(distance_nuclear/2)*2 
egen tag_distance_id=tag(distance_id mob_1971)
foreach year in 1971 1981 1991 2001 2011 {
egen share_distance_`year'=mean(share_labor_oa_`year'), by(distance_id mob_1971)
egen temp=mean(share_labor_oa_`year'), by(mob_1971)
replace share_distance_`year'=share_distance_`year'/temp
replace share_labor_oa_`year'=share_labor_oa_`year'/temp
drop temp
}
#delimit ;
twoway lpoly share_labor_oa_1971 distance_nuclear if distance_id<60 & mob_1971==1, color(dknavy) bwidth(4) ||
scatter share_distance_1971 distance_id if tag_distance_id & distance_id<60 & mob_1971==1, color(dknavy) msize(small) ||
lpoly share_labor_oa_2001 distance_nuclear if distance_id<60 & mob_1971==1, color(cranberry) bwidth(4) ||
scatter share_distance_2001 distance_id if tag_distance_id & distance_id<60 & mob_1971==1, color(cranberry) msize(small)
xline(20)
xtitle("Distance to NPP(kms)")
ytitle("Share of low-skilled workers")
ylabel(0.7 1 1.3)
bgcolor("white") graphregion(color(white) margin(l-3 r+1)) 
legend(order(1 3) ring(0) nobox region(lstyle(none)) label(1 "1971") label(3 "2001") cols(1) pos(5))
scale(1.3)
;
#delimit cr
graph export "Figure_5a.png", as(png) replace width(1000)

#delimit ;
twoway lpoly share_labor_oa_1971 distance_nuclear if distance_id<60 & mob_1971==0, color(dknavy) bwidth(4) ||
scatter share_distance_1971 distance_id if tag_distance_id & distance_id<60 & mob_1971==0, color(dknavy) msize(small) ||
lpoly share_labor_oa_2001 distance_nuclear if distance_id<60 & mob_1971==0, color(cranberry) bwidth(4) ||
scatter share_distance_2001 distance_id if tag_distance_id & distance_id<60 & mob_1971==0, color(cranberry) msize(small)
xline(20)
xtitle("Distance to NPP(kms)")
ytitle("Share of low-skilled workers")
ylabel(0.7 1 1.3)
bgcolor("white") graphregion(color(white) margin(l-3 r+1)) 
legend(order(1 3) ring(0) nobox region(lstyle(none)) label(1 "1971") label(3 "2001") cols(1) pos(5))
scale(1.3)
;
#delimit cr
graph export "Figure_5b.png", as(png) replace width(1000)
drop distance_id tag_distance_id share_distance_*

use "final_history.dta", clear
generate distance_id=floor(distance_nuclear/2)*2
egen tag_distance_id=tag(distance_id mob_1971)
foreach year in 1971 1981 1991 2001 {
egen share_distance_`year'=mean(pop_`year'), by(distance_id mob_1971)
egen temp=mean(pop_`year'), by(mob_1971)
replace share_distance_`year'=share_distance_`year'/temp
replace pop_`year'=pop_`year'/temp
drop temp
}
#delimit ;
twoway lpoly pop_1971 distance_nuclear if distance_id<60 & mob_1971==1, color(dknavy) bwidth(4) ||
scatter share_distance_1971 distance_id if tag_distance_id & distance_id<60 & mob_1971==1, color(dknavy) msize(small) ||
lpoly pop_2001 distance_nuclear if distance_id<60 & mob_1971==1, color(cranberry) bwidth(4) ||
scatter share_distance_2001 distance_id if tag_distance_id & distance_id<60 & mob_1971==1, color(cranberry) msize(small)
xline(20)
xtitle("Distance to NPP(kms)")
ytitle("Population")
ylabel(0.7 1 1.3)
bgcolor("white") graphregion(color(white) margin(l-3 r+1)) 
legend(order(1 3) ring(0) nobox region(lstyle(none)) label(1 "1971") label(3 "2001") cols(1) pos(5))
scale(1.3)
;
#delimit cr
graph export "Figure_5c.png", as(png) replace width(1000)

#delimit ;
twoway lpoly pop_1971 distance_nuclear if distance_id<60 & mob_1971==0, color(dknavy) bwidth(2) ||
scatter share_distance_1971 distance_id if tag_distance_id & distance_id<60 & mob_1971==0, color(dknavy) msize(small) ||
lpoly pop_2001 distance_nuclear if distance_id<60 & mob_1971==0, color(cranberry) bwidth(2) ||
scatter share_distance_2001 distance_id if tag_distance_id & distance_id<60 & mob_1971==0, color(cranberry) msize(small)
xline(20)
xtitle("Distance to NPP(kms)")
ytitle("Population")
ylabel(0.7 1 1.3)
bgcolor("white") graphregion(color(white) margin(l-3 r+1)) 
legend(order(1 3) ring(0) nobox region(lstyle(none)) label(1 "1971") label(3 "2001") cols(1) pos(5))
scale(1.3)
;
#delimit cr
graph export "Figure_5d.png", as(png) replace width(1000)
drop distance_id tag_distance_id share_distance_*

* *********************************
* ****** Appendix Figures *********
* *********************************

* Figure A1: Effect of the Fukushima accident on the housing market--quantile regressions

use "final_transaction.dta", clear
generate q=.
replace q=.10 if _n==1
replace q=.25 if _n==2
replace q=.50 if _n==3
replace q=.75 if _n==4
replace q=.90 if _n==5
generate qestimate=.
generate qvar=.
global sample "if ln_price_f!=."
global controls "i.property_type_i##time_treatment i.old_new_i##time_treatment i.tenure_i##time_treatment c.rank_deprivation_score##time_treatment"
global vary ln_price_f
qreg ${vary} treatment_nuclear##time_treatment i.group_nuclear##i.time_treatment ${controls} ${sample}, quantile(.10) vce(robust)
replace qestimate=_b[1.treatment_nuclear#1.time_treatment] if _n==1
replace qvar=_se[1.treatment_nuclear#1.time_treatment] if _n==1
qreg ${vary} treatment_nuclear##time_treatment i.group_nuclear##i.time_treatment ${controls} ${sample}, quantile(.25) vce(robust)
replace qestimate=_b[1.treatment_nuclear#1.time_treatment] if _n==2
replace qvar=_se[1.treatment_nuclear#1.time_treatment] if _n==2
qreg ${vary} treatment_nuclear##time_treatment i.group_nuclear##i.time_treatment ${controls} ${sample}, quantile(.50) vce(robust)
replace qestimate=_b[1.treatment_nuclear#1.time_treatment] if _n==3
replace qvar=_se[1.treatment_nuclear#1.time_treatment] if _n==3
qreg ${vary} treatment_nuclear##time_treatment i.group_nuclear##i.time_treatment ${controls} ${sample}, quantile(.75) vce(robust)
replace qestimate=_b[1.treatment_nuclear#1.time_treatment] if _n==4
replace qvar=_se[1.treatment_nuclear#1.time_treatment] if _n==4
qreg ${vary} treatment_nuclear##time_treatment i.group_nuclear##i.time_treatment ${controls} ${sample}, quantile(.90) vce(robust)
replace qestimate=_b[1.treatment_nuclear#1.time_treatment] if _n==5
replace qvar=_se[1.treatment_nuclear#1.time_treatment] if _n==5
generate q5=qestimate-1.96*qvar
generate q95=qestimate+1.96*qvar
sort q
#delimit ;
twoway scatter qestimate q, color(dknavy) ||
rcap q5 q95 q, color(dknavy)
xtitle("Quantile")
ytitle("Treatment effect")
yline(0)
xlabel(.10 .25 .50 .75 .90)
bgcolor("white") graphregion(color(white) margin(l-3 r+1)) 
legend(off) scale(1.2)
;
#delimit cr
graph export "Figure_A1.png", as(png) replace width(1000)

* Figure E1: Vote shares for the Green Party at the UK General Elections in 2010 and 2015

use "final.dta", clear
generate distance_id=floor(distance_nuclear/10)*10
egen tag_distance_id=tag(distance_id)
egen Green_vote_2010_d=mean(Green_vote_2010), by(distance_id)
egen Green_vote_2015_d=mean(Green_vote_2015), by(distance_id)
#delimit ;
twoway lpoly Green_vote_2010_d distance_id if tag_distance_id & distance_id<100, color(dknavy) bwidth(6) ||
scatter Green_vote_2010_d distance_id if tag_distance_id & distance_id<100, color(dknavy) msize(small) ||
lpoly Green_vote_2015_d distance_id if tag_distance_id & distance_id<100, color(cranberry) bwidth(6) ||
scatter Green_vote_2015_d distance_id if tag_distance_id & distance_id<100, color(cranberry) msize(small)
xtitle("Distance to NPP (kms)")
ytitle("Vote for Green party")
bgcolor("white") graphregion(color(white) margin(l-3 r+1)) 
legend(off) scale(1.2)
;
#delimit cr
graph export "Figure_E1.png", as(png) replace width(1000)
